// @ts-ignore
/* eslint-disable */
import request from '@/request'

/** 此处后端没有提供注释 POST /main/get/car/info */
export async function getCarInfo(body: API.Car, options?: { [key: string]: any }) {
  return request<API.BaseResponseCar>('/main/get/car/info', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 此处后端没有提供注释 GET /main/hello */
export async function hello(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.helloParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseString>('/main/hello', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** 此处后端没有提供注释 POST /main/upload */
export async function file(body: {}, file1?: File, file2?: File, options?: { [key: string]: any }) {
  const formData = new FormData()

  if (file1) {
    formData.append('file1', file1)
  }

  if (file2) {
    formData.append('file2', file2)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<string>('/main/upload', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  })
}
